clear all
set more off
tempfile ubigeo temp

** DATA
use mergedp, clear
keep if voted != .

local listaV vote_matter voted voted_null voted_blank
local listaP partN part_party part_sport part_milk part_neigh part_proff part_water part_ronda part_apafa
local listaD dem_works dem_matters1 gov_demo1 gov_auto1

label var vote_matter "Vote Matters"
label var voted "Voted in 2006"
label var voted_null "Voted Null"
label var voted_blank "Voted Blank"

label var partN "N. of Organisations"
label var part_party "Pol. Party"
label var part_sport "Sporting Org."
label var part_proff "Professional Org."
label var part_neigh "Neighbours Org."
label var part_ronda "Self-Defense Org."
label var part_water "Irrigation Comm."
label var part_apafa "Parents Org."
label var part_milk "Glass of Milk"

label var dem_works "Democracy Works"
label var dem_matters1 "Democracy Matters"
label var gov_demo1 "Prefers Democratic Government"
label var gov_auto1 "Prefers Autocratic Government"

replace partN = partN / 100

foreach var of varlist `listaV' `listaP' `listaD' {
	replace `var' = `var' * 100
	global name_`var' : var label `var'

	sum `var' 
	glo m_`var' : di %12.1fc r(mean)
	glo sd_`var' : di %12.1fc r(sd)
	glo n_`var' : di %12.0fc r(N)
	glo min_`var' : di %12.0fc r(min)
	glo max_`var' : di %12.0fc r(max)
	
	sum `var' if todoAT == 0
	glo m0_`var' : di %12.1fc r(mean)
	glo sd0_`var' : di %12.3fc r(sd)

	sum `var' if todoAT == 1
	glo m1_`var' : di %12.1fc r(mean)
	glo sd1_`var' : di %12.1fc r(sd)
}

texdoc init Table_2.tex , replace
tex \begin{table}[h]
tex \caption{Summary statistics for dependent variables}
tex \label{tab:Table_2}
tex \begin{center}
tex \resizebox{15cm}{!}{
	tex \begin{tabular}{lccccccccccccccccccccccccccccccccccccccc} \hline \hline
    tex \\
	tex 					&	&  & \multicolumn{3}{c}{Mean} & Overall & Min  &  Max    \\					
	tex 					&	&  & & & Non- & standard &   &     \\					
	tex 					&	& N & Overall& Exposed & Exposed & deviation &   &      \\					
	tex \\
	tex \hline
	tex \\
	tex & \multicolumn{4}{l}{\emph{a. Voting Behavior}} \\
 	foreach var of varlist `listaV'  {
     tex  \quad ${name_`var'}   & &  ${n_`var'} & ${m_`var'} & ${m1_`var'} & ${m0_`var'}  &  ${sd_`var'} &  ${min_`var'} & ${max_`var'}  \\
	}
	tex \\
	tex & \multicolumn{4}{l}{\emph{b. Participation}} \\
 	foreach var of varlist `listaP'  {
     tex  \quad ${name_`var'}   & &  ${n_`var'} & ${m_`var'} & ${m1_`var'} & ${m0_`var'}  &  ${sd_`var'} &  ${min_`var'} & ${max_`var'}  \\
	}
	tex \\
	tex & \multicolumn{4}{l}{\emph{c. Democratic Beliefs}} \\
 	foreach var of varlist `listaD'  {
     tex  \quad ${name_`var'}   & &  ${n_`var'} & ${m_`var'} & ${m1_`var'} & ${m0_`var'}  &  ${sd_`var'} &  ${min_`var'} & ${max_`var'}  \\
	}
	tex \\ \hline \hline
    tex \end{tabular}}
tex \end{center}
tex \end{table}
